home *** CD-ROM | disk | FTP | other *** search
- /*
- File: Window.h
-
- Contains: Definition of TWindow, a base class which provides a
- framework for building way-cool windows which even John
- Sullivan would be happy with. Floating windows and “smart
- zooming” algorithms are based on code samples provided by
- Dean Yu.
-
- Written by: Dave Falkenburg, Dean Yu
-
- Copyright: © 1993-94 by Dave Falkenburg, all rights reserved.
-
- Change History (most recent first):
-
- */
-
- #ifndef _WINDOW_
- #define _WINDOW_
-
- #ifndef __TYPES__
- #include <Types.h>
- #endif
-
- #ifndef __WINDOWS__
- #include <Windows.h>
- #endif
-
- #ifndef __EVENTS__
- #include <Events.h>
- #endif
-
- #ifndef __DRAG__
- #include <Drag.h>
- #endif
-
- // Useful synonyms
-
- #define kNormalWindow false
- #define kFloatingWindow true
-
- typedef short WindowTemplateID;
-
-
- class TWindow
- {
- protected:
- WindowPtr fWindow;
- Boolean fIsFloatingWindow;
- Boolean fIsVisible;
-
- public:
- TWindow();
- virtual ~TWindow();
-
- // Event routing methods
-
- virtual Boolean EventFilter(EventRecord * theEvent);
-
- // Methods you shouldn’t need to override, but might need to
-
- virtual void CreateWindow(Boolean isFloating);
- virtual void Select(void);
- virtual void Drag(Point startPoint);
- virtual void Grow(Point startPoint);
- virtual void Zoom(short zoomState);
-
- // Wrapper for ShowHide so we can correctly show and hide
- // floating windows when a major context switch occurs
-
- virtual void ShowOrHide(Boolean showFlag);
-
- // Methods which MUST be overridden:
-
- virtual WindowPtr MakeNewWindow(WindowPtr behindWindow) = 0;
-
-
- // Methods which probably should be overridden
-
- virtual void AdjustCursor(EventRecord * anEvent);
- virtual void Idle(EventRecord * anEvent);
- virtual void Activate(Boolean activating);
- virtual void Draw(void);
- virtual void Click(EventRecord * anEvent);
- virtual void KeyDown(EventRecord * anEvent);
-
- virtual void GetPerfectWindowSize(Rect * perfectSize);
- virtual void GetWindowSizeLimits(Rect * limits);
- virtual void AdjustForNewWindowSize(Rect * oldRect,Rect * newRect);
-
-
- // Window property accessor methods…
- // …watch for new ones when we add scripting support
-
- virtual Boolean IsVisible(void);
-
- virtual Boolean CanClose(void);
- virtual Boolean Close(void);
- virtual Boolean DeleteAfterClose(void);
-
- virtual Boolean CanEdit(void);
- virtual void DoEditMenu(short menuCode);
-
-
- // Methods for use with the Drag Manager
-
- virtual OSErr HandleDrag(DragTrackingMessage dragMessage,DragReference theDrag);
- virtual OSErr HandleDrop(DragReference theDragRef);
- };
-
-
- // Utility Functions:
-
- TWindow * GetWindowObject(WindowPtr aWindow);
-
- WindowPtr LastFloatingWindow(void);
- WindowPtr FrontNonFloatingWindow(void);
-
- void HiliteAndActivateWindow(WindowPtr aWindow,Boolean active);
- void SuspendResumeWindows(Boolean resuming);
- void HiliteWindowsForModalDialog(Boolean hiliting);
-
- pascal OSErr CallWindowDragTrackingHandler(DragTrackingMessage message,WindowPtr theWindow,void *handlerRefCon,DragReference theDragRef);
- pascal OSErr CallWindowDragReceiveHandler(WindowPtr theWindow, void *handlerRefCon,DragReference theDragRef);
-
- #endif
-